<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片切换</title>
    <style>
        #content {
            border: 1px solid red;
        }

        .center {
            margin: 10px auto;
            width: 450px;
            height: 300px;
            position: relative;
        }

        .center>img {
            width: 100%;
            height: 100%;
        }

        .btn {
            position: absolute;

            width: 25px;
            background-color: aliceblue;
            text-decoration: none;
        }

        .right {
            left: 0;
            top: 150px;
        }

        .left {
            right: 0;
            bottom: 125px;
        }
    </style>
</head>

<body>
    <div id="content">
        <div class="center">
            <!-- 图片 -->
            <img :src="imgArr[index]" alt="">
            <!-- 右箭头 -->
            <div class="btn right" @click="prev" v-show="index!=0">< </div> 
            <!-- 左箭头 -->
            <div class="btn left" @click="next" v-show="index<imgArr.length-1">></div>
        </div>
    </div>
            <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
            <script>
                var app = new Vue({
                    el: "#content",
                    data: {
                        imgArr: [
                            "./images/b.zol-img.com.jpeg",
                            "./images/dik.img.kttpdq.jpeg",
                            "./images/downloadfile.jpeg",
                            "./images/gss0.baidu.jpeg",
                            "./images/i0.hdslb.jpeg"
                        ],
                        index: 0
                    },
                    methods: {
                        prev: function () {
                            this.index--;
                        },
                        next: function () {
                            this.index++;
                        }
                    },
                })
            </script>

</body>

</html>